// 套餐管理相关接口
import request from '@/utils/request'

/**
 * 套餐分页查询
 * @param {Object} params - 查询参数 {name, categoryId, status, page, pageSize}
 * @returns {Promise}
 */
export const getSetmealPage = (params) => {
  return request({
    url: '/admin/setmeal/page',
    method: 'get',
    params
  })
}

/**
 * 新增套餐
 * @param {Object} data - 套餐信息 {name, categoryId, price, image, description, status, setmealDishes}
 * @returns {Promise}
 */
export const addSetmeal = (data) => {
  return request({
    url: '/admin/setmeal',
    method: 'post',
    data
  })
}

/**
 * 修改套餐
 * @param {Object} data - 套餐信息 {id, name, categoryId, price, image, description, status, setmealDishes}
 * @returns {Promise}
 */
export const updateSetmeal = (data) => {
  return request({
    url: '/admin/setmeal',
    method: 'put',
    data
  })
}

/**
 * 批量删除套餐
 * @param {String} ids - 套餐id，多个id用逗号分隔
 * @returns {Promise}
 */
export const deleteSetmeal = (ids) => {
  return request({
    url: '/admin/setmeal',
    method: 'delete',
    params: { ids }
  })
}

/**
 * 根据id查询套餐
 * @param {Number} id - 套餐id
 * @returns {Promise}
 */
export const getSetmealById = (id) => {
  return request({
    url: `/admin/setmeal/${id}`,
    method: 'get'
  })
}

/**
 * 套餐起售、停售
 * @param {Number} id - 套餐id
 * @param {Number} status - 状态(1:起售, 0:停售)
 * @returns {Promise}
 */
export const updateSetmealStatus = (id, status) => {
  return request({
    url: `/admin/setmeal/status/${status}`,
    method: 'post',
    params: { id }
  })
}